#include "stdafx.h"
#include "SgTexture.h"


CSgTexture::CSgTexture(CTexture* tex)
{
	m_child = NULL;
	m_texture = tex;
}

CSgTexture::~CSgTexture(void)
{
	//if (m_child != NULL)
	//	m_child->DecRef();
}

void CSgTexture::Render()
{
	if (m_child != NULL)
	{
		glEnable(GL_TEXTURE_2D);
		// textures only work well with a white material w/ GL_MODULATE
		GLfloat white[] = {1.0f, 1.0f, 1.0f, 1.0f};
		//glColor4fv(white);
		glMaterialfv(GL_FRONT, GL_DIFFUSE, white);
		glMaterialfv(GL_FRONT, GL_SPECULAR, white);

		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glBindTexture(GL_TEXTURE_2D, m_texture->TexName());
		m_child->Render();
		glDisable(GL_TEXTURE_2D);
	}
}